package com.linjiahao.userCenter.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.linjiahao.commonUtil.base.WxNumberUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @ClassName ChatUserInfo
 * @TableName chat_user_info
 * @Description: 实体类
 * @Author linjiahao
 * @Date 29/12/2021
 **/
@TableName(value ="chat_user_info")
@Data
public class ChatUserInfo implements Serializable {

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * 自增id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 用户id
     */
    @JsonSerialize(using= ToStringSerializer.class)
    private Long userId;

    /**
     * 昵称
     */
    private String nickName;

    /**
     * 手机号码
     */
    private String phone;

    /**
     * 头像
     */
    private String img;

    /**
     * 性别 0：男 1：女
     */
    private Integer sex;

    /**
     * 地区
     */
    private String address;

    /**
     * 自定义账号
     */
    private String wxNumber;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    /**
     * 是否删除
     */
    private Integer isDelete;


    /**
    * 新增用户初始化
    * */
    public ChatUserInfo getInitUserInfo(String phone){
        ChatUserInfo userInfo = new ChatUserInfo();
        userInfo.setUserId(IdWorker.getId());
        userInfo.setNickName(phone);
        userInfo.setPhone(phone);
        //默认头像
        userInfo.setImg("https://linjiahao.oss-cn-shenzhen.aliyuncs.com/2021/12/12/0165ec928ddb416ab6289f2d9e0155fd.jpg");
        userInfo.setWxNumber(WxNumberUtil.getRandomStirng(phone));
        return userInfo;
    }
}
